package com.ruoyi.web.controller.danger;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.entity.SysUserManage;
import com.ruoyi.system.service.SysUserManageService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SysUserManage)表控制层
 *
 * @author makejava
 * @since 2022-12-01 16:47:39
 */
@RestController
@RequestMapping("sysUserManage")
public class SysUserManageController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private SysUserManageService sysUserManageService;

    /**
     * 分页查询
     *
     * @param sysUserManage 筛选条件
     * @return 查询结果
     */
    @GetMapping("/list")
    public TableDataInfo queryByPage(SysUserManage sysUserManage) {
        startPage();
        List<SysUserManage> sysUserManages = this.sysUserManageService.queryByPage(sysUserManage);
        return getDataTable(sysUserManages);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public AjaxResult queryById(@PathVariable("id") Integer id) {
        return AjaxResult.success(this.sysUserManageService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param sysUserManage 实体
     * @return 新增结果
     */
    @PostMapping("/create")
    public AjaxResult add(@RequestBody SysUserManage sysUserManage) {
        return AjaxResult.success(this.sysUserManageService.insert(sysUserManage));
    }

    /**
     * 编辑数据
     *
     * @param sysUserManage 实体
     * @return 编辑结果
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody SysUserManage sysUserManage) {
        return AjaxResult.success(this.sysUserManageService.update(sysUserManage));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @GetMapping("/delete")
    public AjaxResult deleteById(Integer id) {
        return AjaxResult.success(this.sysUserManageService.deleteById(id));
    }

}

